// symbol.h

// Copyright (C) 2010  traxex

// Author: 	traxex <traxex@yahoo.cn>
// Created: 	05 Aug 2010
// Version: 	1.0

#pragma once

namespace Traxex{
namespace Cuda{

template<typename T>class Symbol{
    T	data;
  public:
    Symbol(){}
    Symbol(const T& t){
	_safecall( cudaMemcpyToSymbol( (const char*)&data, &t, sizeof(T), 0, cudaMemcpyHostToDevice));
    }
    Symbol( const Symbol &s){
	T t = (T)s;
	_safecall( cudaMemcpyToSymbol( (const char*)&data, &t, sizeof(T), 0, cudaMemcpyDeviceToDevice));
    }

    Symbol& operator=( const T& t){
	_safecall( cudaMemcpyToSymbol( (const char*)&data, &t, sizeof(T), 0, cudaMemcpyHostToDevice));
	return *this;
    }

    operator T() const{
	return data;
    }	
};

}
}
